home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / superman.c < prev    next >
C/C++ Source or Header  |  2000-05-04  |  12KB  |  377 lines

  1. /***************************************************************************
  2.  
  3. Superman memory map
  4.  
  5. driver by Richard Bush, Howie Cohen
  6.  
  7. CPU 1 : 68000, uses irq 6
  8.  
  9. 0x000000 - 0x07ffff : ROM
  10. 0x300000 ??
  11. 0x400000 ??
  12. 0x500000 - 0x50000f : Dipswitches a & b, 4 bits to each word
  13. 0x600000 ?? 0, 10, 0x4001, 0x4006
  14. 0x700000 ??
  15. 0x800000 - 0x800003 : sound chip
  16. 0x900000 - 0x900fff : c-chip shared RAM space
  17. 0xb00000 - 0xb00fff : palette RAM, words in the format xRRRRRGGGGGBBBBB
  18. 0xc00000 ??
  19. 0xd00000 - 0xd007ff : video attribute RAM
  20.     0000 - 03ff : sprite y coordinate
  21.     0400 - 07ff : tile x & y scroll
  22. 0xe00000 - 0xe00fff : object RAM
  23.     0000 - 03ff : sprite number (bit mask 0x3fff)
  24.                   sprite y flip (bit mask 0x4000)
  25.                   sprite x flip (bit mask 0x8000)
  26.     0400 - 07ff : sprite x coordinate (bit mask 0x1ff)
  27.                   sprite color (bit mask 0xf800)
  28.     0800 - 0bff : tile number (bit mask 0x3fff)
  29.                   tile y flip (bit mask 0x4000)
  30.                   tile x flip (bit mask 0x8000)
  31.     0c00 - 0fff : tile color (bit mask 0xf800)
  32. 0xe01000 - 0xe03fff : unused(?) portion of object RAM
  33.  
  34. TODO:
  35.     * Optimize rendering
  36.     * Does high score save work consistently?
  37.  
  38. ***************************************************************************/
  39.  
  40. #include "driver.h"
  41. #include "cpu/m68000/m68000.h"
  42. #include "vidhrdw/generic.h"
  43.  
  44.  
  45. WRITE_HANDLER( supes_attribram_w );
  46. READ_HANDLER( supes_attribram_r );
  47. WRITE_HANDLER( supes_videoram_w );
  48. READ_HANDLER( supes_videoram_r );
  49. void superman_vh_screenrefresh (struct osd_bitmap *bitmap, int full_refresh);
  50. int superman_vh_start (void);
  51. void superman_vh_stop (void);
  52.  
  53. extern size_t supes_videoram_size;
  54. extern size_t supes_attribram_size;
  55.  
  56. extern unsigned char *supes_videoram;
  57. extern unsigned char *supes_attribram;
  58.  
  59. /* Routines found in sndhrdw/rastan.c */
  60. READ_HANDLER( rastan_a001_r );
  61. WRITE_HANDLER( rastan_a000_w );
  62. WRITE_HANDLER( rastan_a001_w );
  63.  
  64. WRITE_HANDLER( rastan_sound_w );
  65. READ_HANDLER( rastan_sound_r );
  66.  
  67. static unsigned char *ram; /* for high score save */
  68.  
  69. void cchip1_init_machine(void);
  70. READ_HANDLER( cchip1_r );
  71. WRITE_HANDLER( cchip1_w );
  72.  
  73. READ_HANDLER( superman_input_r )
  74. {
  75.     switch (offset)
  76.     {
  77.         case 0x00:
  78.             return readinputport (0);
  79.         case 0x02:
  80.             return readinputport (1);
  81.         case 0x04:
  82.             return readinputport (2);
  83.         case 0x06:
  84.             return readinputport (3);
  85.         default:
  86.             logerror("superman_input_r offset: %04x\n", offset);
  87.             return 0xff;
  88.     }
  89. }
  90.  
  91.  
  92.  
  93. static WRITE_HANDLER( taito68k_sound_bankswitch_w )
  94. {
  95.     unsigned char *RAM = memory_region(REGION_CPU2);
  96.  
  97.     int banknum = ( data - 1 ) & 3;
  98.  
  99.     cpu_setbank( 2, &RAM[ 0x10000 + ( banknum * 0x4000 ) ] );
  100. }
  101.  
  102.  
  103. static struct MemoryReadAddress superman_readmem[] =
  104. {
  105.     { 0x000000, 0x07ffff, MRA_ROM },
  106.     { 0x500000, 0x50000f, superman_input_r },    /* DSW A/B */
  107.     { 0x800000, 0x800003, rastan_sound_r },
  108.     { 0x900000, 0x900fff, cchip1_r } ,
  109.     { 0xb00000, 0xb00fff, paletteram_word_r },
  110.     { 0xd00000, 0xd007ff, supes_attribram_r },
  111.     { 0xe00000, 0xe03fff, supes_videoram_r },
  112.     { 0xf00000, 0xf03fff, MRA_BANK1 },    /* Main RAM */
  113.     { -1 }  /* end of table */
  114. };
  115.  
  116. static struct MemoryWriteAddress superman_writemem[] =
  117. {
  118.     { 0x000000, 0x07ffff, MWA_ROM },
  119.     { 0x800000, 0x800003, rastan_sound_w },
  120.     { 0x900000, 0x900fff, cchip1_w },
  121.     { 0xb00000, 0xb00fff, paletteram_xRRRRRGGGGGBBBBB_word_w, &paletteram },
  122.     { 0xd00000, 0xd007ff, supes_attribram_w, &supes_attribram, &supes_attribram_size },
  123.     { 0xe00000, 0xe03fff, supes_videoram_w, &supes_videoram, &supes_videoram_size },
  124.     { 0xf00000, 0xf03fff, MWA_BANK1, &ram },            /* Main RAM */
  125.     { -1 }  /* end of table */
  126. };
  127.  
  128. static struct MemoryReadAddress sound_readmem[] =
  129. {
  130.     { 0x0000, 0x3fff, MRA_ROM },
  131.     { 0x4000, 0x7fff, MRA_BANK2 },
  132.     { 0xc000, 0xdfff, MRA_RAM },
  133.     { 0xe000, 0xe000, YM2610_status_port_0_A_r },
  134.     { 0xe001, 0xe001, YM2610_read_port_0_r },
  135.     { 0xe002, 0xe002, YM2610_status_port_0_B_r },
  136.     { 0xe200, 0xe200, MRA_NOP },
  137.     { 0xe201, 0xe201, rastan_a001_r },
  138.     { 0xea00, 0xea00, MRA_NOP },
  139.     { -1 }  /* end of table */
  140. };
  141.  
  142. static struct MemoryWriteAddress sound_writemem[] =
  143. {
  144.     { 0x0000, 0x7fff, MWA_ROM },
  145.     { 0xc000, 0xdfff, MWA_RAM },
  146.     { 0xe000, 0xe000, YM2610_control_port_0_A_w },
  147.     { 0xe001, 0xe001, YM2610_data_port_0_A_w },
  148.     { 0xe002, 0xe002, YM2610_control_port_0_B_w },
  149.     { 0xe003, 0xe003, YM2610_data_port_0_B_w },
  150.     { 0xe200, 0xe200, rastan_a000_w },
  151.     { 0xe201, 0xe201, rastan_a001_w },
  152.     { 0xe400, 0xe403, MWA_NOP }, /* pan */
  153.     { 0xee00, 0xee00, MWA_NOP }, /* ? */
  154.     { 0xf000, 0xf000, MWA_NOP }, /* ? */
  155.     { 0xf200, 0xf200, taito68k_sound_bankswitch_w }, /* bankswitch? */
  156.     { -1 }  /* end of table */
  157. };
  158.  
  159. INPUT_PORTS_START( superman )
  160.     PORT_START /* DSW A */
  161.     PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) )
  162.     PORT_DIPSETTING(    0x01, DEF_STR( Off ))
  163.     PORT_DIPSETTING(    0x00, DEF_STR( On ))
  164.     PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) )
  165.     PORT_DIPSETTING(    0x02, DEF_STR( Off ))
  166.     PORT_DIPSETTING(    0x00, DEF_STR( On ))
  167.     PORT_SERVICE( 0x04, IP_ACTIVE_LOW )
  168.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) )
  169.     PORT_DIPSETTING(    0x08, DEF_STR( Off ))
  170.     PORT_DIPSETTING(    0x00, DEF_STR( On ))
  171.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED )
  172.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED )
  173.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
  174.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
  175.  
  176.     PORT_START /* DSW B */
  177.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coin_A ) )
  178.     PORT_DIPSETTING(    0x00, DEF_STR( 4C_1C ) )
  179.     PORT_DIPSETTING(    0x01, DEF_STR( 3C_1C ) )
  180.     PORT_DIPSETTING(    0x02, DEF_STR( 2C_1C ) )
  181.     PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
  182.     PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Coin_B ) )
  183.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_2C ) )
  184.     PORT_DIPSETTING(    0x08, DEF_STR( 1C_3C ) )
  185.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_4C ) )
  186.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_6C ) )
  187.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED )
  188.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED )
  189.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
  190.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
  191.  
  192.     PORT_START /* DSW c */
  193.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
  194.     PORT_DIPSETTING(    0x02, "Easy" )
  195.     PORT_DIPSETTING(    0x03, "Normal" )
  196.     PORT_DIPSETTING(    0x01, "Hard" )
  197.     PORT_DIPSETTING(    0x00, "Very Hard" )
  198.     PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )
  199.     PORT_DIPSETTING(    0x0c, "50k and every 150k" )
  200.     PORT_DIPSETTING(    0x04, "Bonus 2??" )
  201.     PORT_DIPSETTING(    0x08, "Bonus 3??" )
  202.     PORT_DIPSETTING(    0x00, "Bonus 4??" )
  203.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED )
  204.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED )
  205.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
  206.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
  207.  
  208.     PORT_START /* DSW D */
  209.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
  210.     PORT_DIPSETTING(    0x02, "2" )
  211.     PORT_DIPSETTING(    0x03, "3" )
  212.     PORT_DIPSETTING(    0x01, "4" )
  213.     PORT_DIPSETTING(    0x00, "5" )
  214.     PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unused ) )
  215.     PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
  216.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  217.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
  218.     PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
  219.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  220.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED )
  221.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED )
  222.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
  223.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
  224.  
  225.     PORT_START      /* IN0 */
  226.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER1 )
  227.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER1 )
  228.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER1 )
  229.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
  230.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  231.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
  232.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  233.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )
  234.  
  235.     PORT_START      /* IN1 */
  236.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
  237.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
  238.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
  239.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  240.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  241.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  242.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  243.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
  244.  
  245.     PORT_START      /* IN2 */
  246.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
  247.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
  248.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 )
  249.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_TILT )
  250.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
  251.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
  252.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  253.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  254. INPUT_PORTS_END
  255.  
  256. #define NUM_TILES 16384
  257. static struct GfxLayout tilelayout =
  258. {
  259.     16,16,  /* 16*16 sprites */
  260.     NUM_TILES,    /* 16384 of them */
  261.     4,           /* 4 bits per pixel */
  262.     { 64*8*NUM_TILES + 8, 64*8*NUM_TILES + 0, 8, 0 },
  263.     { 0, 1, 2, 3, 4, 5, 6, 7,
  264.         8*16, 8*16+1, 8*16+2, 8*16+3, 8*16+4, 8*16+5, 8*16+6, 8*16+7 },
  265.     { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
  266.         16*16, 17*16, 18*16, 19*16, 20*16, 21*16, 22*16, 23*16 },
  267.  
  268.     64*8    /* every sprite takes 64 consecutive bytes */
  269. };
  270. #undef NUM_TILES
  271.  
  272. static struct GfxDecodeInfo superman_gfxdecodeinfo[] =
  273. {
  274.     { REGION_GFX1, 0x000000, &tilelayout,    0, 256 },     /* sprites & playfield */
  275.     { -1 } /* end of array */
  276. };
  277.  
  278. /* handler called by the YM2610 emulator when the internal timers cause an IRQ */
  279. static void irqhandler(int irq)
  280. {
  281.     cpu_set_irq_line(1,0,irq ? ASSERT_LINE : CLEAR_LINE);
  282. }
  283.  
  284.  
  285. static struct YM2610interface ym2610_interface =
  286. {
  287.     1,    /* 1 chip */
  288.     8000000,    /* 8 MHz ?????? */
  289.     { 30 },
  290.     { 0 },
  291.     { 0 },
  292.     { 0 },
  293.     { 0 },
  294.     { irqhandler },
  295.     { REGION_SOUND1 },
  296.     { REGION_SOUND1 },
  297.     { YM3012_VOL(60,MIXER_PAN_LEFT,60,MIXER_PAN_RIGHT) }
  298. };
  299.  
  300.  
  301. static struct MachineDriver machine_driver_superman =
  302. {
  303.     /* basic machine hardware */
  304.     {
  305.         {
  306.             CPU_M68000,
  307.             8000000,    /* 8 MHz? */
  308.             superman_readmem,superman_writemem,0,0,
  309.             m68_level6_irq,1
  310.         },
  311.         {
  312.             CPU_Z80,
  313.             4000000,    /* 4 MHz ??? */
  314.             sound_readmem, sound_writemem,0,0,
  315.             ignore_interrupt,0    /* IRQs are triggered by the YM2610 */
  316.         }
  317.     },
  318.     60, DEFAULT_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  319.     1,
  320.     cchip1_init_machine,
  321.  
  322.     /* video hardware */
  323.     48*8, 32*8, { 2*8, 46*8-1, 2*8, 32*8-1 },
  324.  
  325.     superman_gfxdecodeinfo,
  326.     4096,4096,
  327.     0,
  328.  
  329.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  330.     0,
  331.     superman_vh_start,
  332.     superman_vh_stop,
  333.     superman_vh_screenrefresh,
  334.  
  335.     /* sound hardware */
  336.     SOUND_SUPPORTS_STEREO,0,0,0,
  337.     {
  338.         {
  339.             SOUND_YM2610,
  340.             &ym2610_interface
  341.         }
  342.     }
  343. };
  344.  
  345.  
  346.  
  347. /***************************************************************************
  348.  
  349.   Game driver(s)
  350.  
  351. ***************************************************************************/
  352.  
  353. ROM_START( superman )
  354.     ROM_REGION( 0x80000, REGION_CPU1 )     /* 512k for 68000 code */
  355.     ROM_LOAD_EVEN( "a10_09.bin", 0x00000, 0x20000, 0x640f1d58 )
  356.     ROM_LOAD_ODD ( "a05_07.bin", 0x00000, 0x20000, 0xfddb9953 )
  357.     ROM_LOAD_EVEN( "a08_08.bin", 0x40000, 0x20000, 0x79fc028e )
  358.     ROM_LOAD_ODD ( "a03_13.bin", 0x40000, 0x20000, 0x9f446a44 )
  359.  
  360.     ROM_REGION( 0x1c000, REGION_CPU2 )     /* 64k for Z80 code */
  361.     ROM_LOAD( "d18_10.bin", 0x00000, 0x4000, 0x6efe79e8 )
  362.     ROM_CONTINUE(           0x10000, 0xc000 ) /* banked stuff */
  363.  
  364.     ROM_REGION( 0x200000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  365.     ROM_LOAD( "f01_14.bin", 0x000000, 0x80000, 0x89368c3e ) /* Plane 0, 1 */
  366.     ROM_LOAD( "h01_15.bin", 0x080000, 0x80000, 0x910cc4f9 )
  367.     ROM_LOAD( "j01_16.bin", 0x100000, 0x80000, 0x3622ed2f ) /* Plane 2, 3 */
  368.     ROM_LOAD( "k01_17.bin", 0x180000, 0x80000, 0xc34f27e0 )
  369.  
  370.     ROM_REGION( 0x80000, REGION_SOUND1 )    /* adpcm samples */
  371.     ROM_LOAD( "e18_01.bin", 0x00000, 0x80000, 0x3cf99786 )
  372. ROM_END
  373.  
  374.  
  375.  
  376. GAMEX( 1988, superman, 0, superman, superman, 0, ROT0, "Taito Corporation", "Superman", GAME_NO_COCKTAIL )
  377.